<template>
  <div class="page-header">
    <slot>
      <a-page-header
        :ghost="ghost"
        :title="title || defaultTitle"
        :sub-title="subTitle"
        @back="() => $router.go(-1)"
      >
      </a-page-header>
    </slot>
  </div>
</template>

<script>
import { useRoute } from "vue-router";
import { computed } from "vue";

export default {
  name: "PageHeader",
  props: {
    title: {
      type: String,
      default: "",
    },
    subTitle: {
      type: String,
      default: "",
    },
    ghost: {
      type: Boolean,
      default: false,
    },
  },
  setup() {
    const route = useRoute();
    const defaultTitle = computed(() => {
      return route.meta.title;
    });
    return {
      defaultTitle,
    };
  },
};
</script>

<style lang="scss" scoped>
// 缩进距离
$indent: calc(var(--padding-layout-main) * -1);
.page-header {
  height: 50px;
  line-height: 50px;
  margin: $indent $indent var(--padding-layout-main) $indent;
  padding: 0 var(--padding-layout-main);
  background: #fff;
}
.ant-page-header {
  padding: 5px 0;
}
:deep(.ant-page-header-heading-title) {
  font-size: 16px !important;
}
</style>
